package com.ita.mutiple;

import java.io.File;

public class ThreadExecutor {

	public static void main(String[] args) {

		String srcPath = "image/image1.jpg";
		String desPath = "image/image2.jpg";
		execute(srcPath, desPath, 5);

	}

	public static void execute(String srcPath, String desPath, int threadNum) {

		File file = new File(srcPath);
		long length = file.length();
		int eachLength = (int) (length / 3);
		for (int i = 0; i < threadNum - 1; i++) {
			FileCopyThread thread=new FileCopyThread(srcPath, desPath, eachLength * i, eachLength * (i + 1));
			thread.start();
			System.out.println("thread"+i);
		}
		FileCopyThread thread = new FileCopyThread(srcPath, desPath, eachLength * (threadNum - 1), (int) length);
		thread.start();
	}

}
